/**
 * 
 */
package info.niwota.home.fm;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

/**
 * @author qiangli
 * 
 */
public class BaseFileActivity extends Activity implements OnClickListener {
	protected final static int RC_VOICEINPUT = 1;
	protected final static int RC_FILECHOOSE = 2;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	protected void startFileChooseActivityForResult() {
		Intent intent = new Intent(this, FileChooseActivity.class);
		startActivityForResult(intent, RC_FILECHOOSE);
	}

	protected void startVoiceInputActivityForResult() {
		Intent intent = new Intent(this, VoiceInputActivity.class);
		startActivityForResult(intent, RC_VOICEINPUT);
	}

	@Override
	protected void onActivityResult(int rc, int resultCode, Intent data) {
		if (resultCode == RESULT_OK) {
			switch (rc) {
			case RC_VOICEINPUT:
				String vi = data.getExtras()
						.getString(Intents.EXTRA_INPUT);
				handleVoiceInputActivityResult(vi, data);
				break;
			case RC_FILECHOOSE:
				String sel = data.getExtras().getString(
						FileChooseActivity.SELECTED_URI);
				handleFileChooseActivityResult(sel, data);
				break;
			default:
				handleActivityResult(rc, resultCode, data);
			}
		} else {
			handleActivityResult(rc, resultCode, data);
		}
	}

	protected void handleFileChooseActivityResult(String sel, Intent data) {
	}

	protected void handleVoiceInputActivityResult(String vi, Intent data) {
	}

	protected void handleActivityResult(int rc, int resultCode, Intent data) {
		// for subclass to handle other results
	}

	public void onClick(View v) {
	}
}
